/*
 *  Copyright 2010 INFN - APE group
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#pragma once

#include <cuqu/version.h>

#ifdef __CUDACC__
#include <cuda.h>
#if CUDA_VERSION < 3000
#error "CUDA v3.0 or newer is required"
#endif // CUDA_VERSION
#endif // __CUDACC__

#if defined(_DEBUG)
#define CUQU_DEBUG 1
#endif

// threadfence_system is needed on Fermi
#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ < 200
#define __threadfence_system() __threadfence()
#endif

// second barrier is necessary to let all blocks wait for the return
// value produced in queue_fetch()/queue_push()
#ifndef CUQU_ENABLE_TAIL_BARRIER
#define CUQU_ENABLE_TAIL_BARRIER 1
#endif
#if !CUQU_ENABLE_TAIL_BARRIER
#warning "CUQU tail barrier is disabled, very dangerous!!!"
#endif

// enable cuqu_trace() calls
#ifndef CUQU_ENABLE_TRACING
#define CUQU_ENABLE_TRACING 0
#endif

// dumps lots of debugging traces
#ifndef CUQU_DEBUG_VERBOSE
#define CUQU_DEBUG_VERBOSE (0 && CUQU_ENABLE_TRACING)
#endif

// enable performance histograms
#ifndef CUQU_ENABLE_PERF_HIST
#define CUQU_ENABLE_PERF_HIST 0
#endif

// invalidates queue slots once they are read in queue_fetch
// it seems necessary to get consistency from pinned memory on Fermi+CUDA4.0
#ifndef CUQU_INVALIDATE_ENTRIES
//#define CUQU_INVALIDATE_ENTRIES 0
#define CUQU_INVALIDATE_ENTRIES 1
#warning "CUQU: performance degradation due to queue entries invalidation"
#endif

#ifndef CUQU_ENABLE_COPY_FENCE
#define CUQU_ENABLE_COPY_FENCE 0
//#define CUQU_ENABLE_COPY_FENCE 1
//#warning "CUQU: performance degradation due to additional __threadfence in entry copy"
#endif

#ifndef CUQU_ENABLE_TAIL_FENCE
#define CUQU_ENABLE_TAIL_FENCE 0
//#define CUQU_ENABLE_TAIL_FENCE 1
//#warning "CUQU: performance degradation due to additional tail __threadfence in fetch/push"
#endif

/*
 * Local variables:
 *  c-indent-level: 4
 *  c-basic-offset: 4
 *  tab-width: 4
 *  indent-tabs-mode: nil
 * End:
 */
